package ms.pc.inf;


import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.AdapterView.OnItemClickListener;

public class AttendingEvents extends ListActivity{
	public MyCustomBaseAdapter adapter;
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		final ListView lv = getListView();
		DBConnectivity objDB =  new DBConnectivity();

		objDB.getAllEventsByUser();
		adapter = new MyCustomBaseAdapter(this, DBConnectivity.arrUserEvents);
		lv.setAdapter(adapter);
		lv.setTextFilterEnabled(true);

		lv.setOnItemClickListener(new OnItemClickListener() {
			public void onItemClick(AdapterView<?> parent, View view,
					int position, long id) {

				Object o = lv.getItemAtPosition(position);
				EventInfo selectedEvent = (EventInfo)o;
				DBConnectivity.selectedEventID = selectedEvent.getEventID();
				DBConnectivity.eventLongitude = selectedEvent.getLongitude();
				DBConnectivity.eventLatitude = selectedEvent.getLatitude();
				

				eventSelected();
			}
		});
	}
	private void eventSelected()
	{
		System.out.println(DBConnectivity.selectedEventID);
		System.out.println(DBConnectivity.eventLatitude);
		System.out.println(DBConnectivity.eventLongitude);
		DBConnectivity objDB =  new DBConnectivity();
		objDB.getUsersByEvents();
		startActivity(new Intent(this, AttendingUsers.class));
	}
}